
// *******************************
// * Raamatukogu - Ravenholm Story  *
// *******************************
// items.lua

local ITEM, SWEP
require( "scripted_ents" )

--------------------------------------------------------------------------------------------------------------
-- Medkit
--------------------------------------------------------------------------------------------------------------

	ITEM = {}

	ITEM.Classname = "rh_medkit"
	ITEM.Printname = "Medical Kit"

	ITEM.Description = "Heals 35 health."
	ITEM.Author = "thomasfn"

	ITEM.Weight = 0.5
	ITEM.Model = "items/healthKit.mdl"

	ITEM.Mins = Vector( -3.6, -7.3, -0.2 )
	ITEM.Maxs = Vector( 14.2, 7.4, 6.1 )

	ITEM.CanPickup = true
	ITEM.CanDrop = true
	ITEM.DropOnDeath = true
	ITEM.CanUse = true

	function ITEM:OnUse( ply )
		if (ply:Health() >= 90) then return ply:ChatPrint( "You don't need to heal!" ) end
		if (ValidEntity( ply )) then
			ply:SetHealth( math.Clamp( ply:Health() + 35, 0, 100 ) )
		end
		self:Destroy()
		ply.Inventory:UpdateNeeded()
	end

	gstore.LoadFactoryFromTable( ITEM )

--------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------
-- Crowbar
--------------------------------------------------------------------------------------------------------------

	ITEM = {}

	ITEM.Classname = "rh_crowbar"
	ITEM.Printname = "Crowbar"

	ITEM.Description = "A crowbar."
	ITEM.Author = "thomasfn"

	ITEM.Weight = 1
	ITEM.Model = "weapons/w_crowbar.mdl"

	ITEM.Mins = Vector( -18.9, -4.7, -4.2 )
	ITEM.Maxs = Vector( 16, 3.6, 5.6 )

	ITEM.CanPickup = true
	ITEM.CanDrop = true
	ITEM.DropOnDeath = true
	ITEM.CanUse = false
	ITEM.CanEquip = true
	
	function ITEM:OnEquip( ply, b )
		if (b) then
			ply:Give( "rhwep_crowbar" )
		else
			ply:StripWeapon( "rhwep_crowbar" )
		end
	end

	gstore.LoadFactoryFromTable( ITEM )

--------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------
-- Sledgehammer
--------------------------------------------------------------------------------------------------------------

	ITEM = {}

	ITEM.Classname = "rh_sledgehammer"
	ITEM.Printname = "Sledge Hammer"

	ITEM.Description = "A makeshift sledge hammer."
	ITEM.Author = "thomasfn"

	ITEM.Weight = 1
	ITEM.Model = "weapons/w_sledgehammer.mdl"

	ITEM.Mins = Vector( -18.9, -4.7, -4.2 )
	ITEM.Maxs = Vector( 16, 3.6, 5.6 )

	ITEM.CanPickup = true
	ITEM.CanDrop = true
	ITEM.DropOnDeath = true
	ITEM.CanUse = false
	ITEM.CanEquip = true
	
	function ITEM:OnEquip( ply, b )
		if (b) then
			ply:Give( "rhwep_shammer" )
		else
			ply:StripWeapon( "rhwep_shammer" )
		end
	end

	gstore.LoadFactoryFromTable( ITEM )

--------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------
-- Crowbar SWEP
--------------------------------------------------------------------------------------------------------------

	SWEP = {}

	SWEP.Base = "base_melee"
	
	SWEP.AttackDelay = 1
	SWEP.AttackDamage = 40
	SWEP.HitDelay = 0.25
	SWEP.SoundDelay = 0.15
	SWEP.SwingSound = Sound( "weapons/iceaxe/iceaxe_swing1.wav" )
	
	SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
	SWEP.WorldModel = "models/weapons/w_crowbar.mdl"
	
	weapons.Register( SWEP, "rhwep_crowbar", true )

--------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------
-- Sledgehammer SWEP
--------------------------------------------------------------------------------------------------------------

	SWEP = {}

	SWEP.Base = "base_melee"
	
	SWEP.AttackDelay = 2
	SWEP.AttackDamage = 100
	SWEP.HitDelay = 0.3
	SWEP.SoundDelay = 0.2
	SWEP.SwingSound = Sound( "weapons/iceaxe/iceaxe_swing1.wav" )
	
	SWEP.SwingSpeed = 0.5
	
	SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
	SWEP.WorldModel = "models/weapons/w_sledgehammer.mdl"
	
	weapons.Register( SWEP, "rhwep_shammer", true )

--------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------
-- Pole
--------------------------------------------------------------------------------------------------------------

	ITEM = {}

	ITEM.Classname = "rh_pole"
	ITEM.Printname = "Pole"

	ITEM.Description = "A wooden pole."
	ITEM.Author = "thomasfn"

	ITEM.Weight = 1
	ITEM.Model = "weapons/w_crowbar.mdl"

	ITEM.Mins = Vector( -3.3, -3.3, -0.3 )
	ITEM.Maxs = Vector( 3.3, 3.3, 57.4 )

	ITEM.CanPickup = true
	ITEM.CanDrop = true
	ITEM.DropOnDeath = true
	ITEM.CanUse = false
	
	function ITEM:CanCombineWith( ply, with )
		print( "Checking if '" .. with.Classname .. "' combines with '" .. self.Classname .. "'..." )
		if (with.Classname == "rh_cinderblock") then return true end
		return false
	end
	
	function ITEM:DoCombineWith( ply, item )
		item:Destroy()
		self:Destroy()
		local item = gstore.CreateItem( "rh_sledgehammer", ply:GetPos() )
		ply:GiveItem( item )
		ply:RefreshInv( 0.5 )
	end

	gstore.LoadFactoryFromTable( ITEM )

--------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------
-- Cinder Block
--------------------------------------------------------------------------------------------------------------

	ITEM = {}

	ITEM.Classname = "rh_cinderblock"
	ITEM.Printname = "Cinder Block"

	ITEM.Description = "A cinder block."
	ITEM.Author = "thomasfn"

	ITEM.Weight = 1
	ITEM.Model = "props_debris/concrete_cynderblock001.mdl"

	ITEM.Mins = Vector( -8.3, -4.3, -4.3 )
	ITEM.Maxs = Vector( 8.2, 4.2, 4.2 )

	ITEM.CanPickup = true
	ITEM.CanDrop = true
	ITEM.DropOnDeath = true
	ITEM.CanUse = false

	gstore.LoadFactoryFromTable( ITEM )

--------------------------------------------------------------------------------------------------------------